package cn.tedu.finance.controller;

import cn.tedu.base.response.JsonResult;
import cn.tedu.finance.pojo.dto.ReimbursementQuery;
import cn.tedu.finance.pojo.dto.ReimbursementSaveParam;
import cn.tedu.finance.pojo.vo.ReimbursementVO;
import cn.tedu.finance.service.ReimbursementService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@Slf4j
@RestController
@RequestMapping("/v1/finance/reimbursement")
public class ReimbursementController {
    @Autowired
    ReimbursementService reimbursementService;

    @GetMapping("select")
    public JsonResult selectReimbursement(ReimbursementQuery reimbursementQuery) {
        log.debug("查询报销申请：{}", reimbursementQuery);
        List<ReimbursementVO> list = reimbursementService.selectReimbusement(reimbursementQuery);
        return JsonResult.ok(list);
    }

    @PostMapping("save")
    public JsonResult saveReimbursement(ReimbursementSaveParam reimbursementSaveParam) {
        log.debug("保存报销申请：{}", reimbursementSaveParam);
        reimbursementService.saveReimbursement(reimbursementSaveParam);
        return JsonResult.ok();
    }

    @PostMapping("cancel/{id}")
    public JsonResult cancelApplication(@PathVariable Long id) {
        log.debug("取消报销申请：{}", id);
        reimbursementService.cancelApplication(id);
        return JsonResult.ok();
    }
}
